﻿Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.GHIElectronics



Namespace GadgeteerApp1


    Partial Public Class Program

        Dim whole As Integer
        Dim remainder As Integer
        Dim font As Font = Resources.GetFont(Resources.FontResources.NinaB)
        ' This is run when the mainboard is powered up or reset. 
        Public Sub ProgramStarted()

            ' Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started")
            display.SimpleGraphics.DisplayText(0.ToString(), font, GT.Color.Yellow, 50, 50)

        End Sub

        ' Dim WithEvents timer As GT.Timer = new GT.Timer(1000)  ' every second (1000ms)

        Private Sub button_ButtonPressed1(sender As Button, state As Button.ButtonState) Handles button.ButtonPressed


            For number = 1 To 127
                Debug.Print(number.ToString())

                led_Strip.TurnAllLedsOff()
                ' display number

                display.SimpleGraphics.ClearNoRedraw()
                display.SimpleGraphics.DisplayText(number.ToString(), font, GT.Color.Yellow, 50, 50)
                whole = number \ 64
                remainder = number Mod 64

                If whole = 1 Then
                    led_Strip(6) = True

                Else
                    led_Strip(6) = False
                End If

                whole = remainder \ 32
                remainder = remainder Mod 32

                If whole = 1 Then
                    led_Strip(5) = True
                Else
                    led_Strip(5) = False
                End If

                whole = remainder \ 16
                remainder = remainder Mod 16
                If whole = 1 Then
                    led_Strip(4) = True
                Else
                    led_Strip(4) = False
                End If

                whole = remainder \ 8
                remainder = remainder Mod 8
                If whole = 1 Then
                    led_Strip(3) = True
                Else
                    led_Strip(3) = False
                End If

                whole = remainder \ 4
                remainder = remainder Mod 4
                If whole = 1 Then
                    led_Strip(2) = True
                Else
                    led_Strip(2) = False
                End If

                whole = remainder \ 2
                remainder = remainder Mod 2
                If whole = 1 Then
                    led_Strip(1) = True
                Else
                    led_Strip(1) = False
                End If
                whole = remainder \ 1
                remainder = remainder Mod 1
                If whole = 1 Then
                    led_Strip(0) = True
                Else
                    led_Strip(0) = False

                End If


            Next

        End Sub


    End Class
End Namespace
